import {defineConfig, loadEnv} from 'vite'
import react from '@vitejs/plugin-react'
import path from "path"

// https://vitejs.dev/config/
export default defineConfig(({mode})=>{

  const env = loadEnv(mode, process.cwd())

  return {
    plugins: [react()],
    resolve:{
      alias:{
        "@":path.resolve(__dirname,'./src')
      }
    },
    server: {
      host: '0.0.0.0',
      port: 8071,
      proxy: {
        [env.VITE_APP_BASE_API]: {
          target: env.VITE_APP_BASE_URL,
          changeOrigin: true,
          ws: false,
          rewrite: path => path.replace(new RegExp(`^${env.VITE_APP_BASE_API}`), ''),
        },
      },
    },
  }

})
